package cn.itcast.nems.order.web.vo;

import cn.itcast.nems.base.dto.EntityExtendAttributeDTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Data
@JsonNaming(value = PropertyNamingStrategies.SnakeCaseStrategy.class)
public class NewOrderVO implements Serializable {
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -7978422616648284520L;

    /**
     * 业务订单编号，需要接入方传递。要求主租户内唯一。
     */
    @NotBlank(message = "业务订单编号不能为空！")
    private String bizOrderNo;

    /**
     * NEW("新报名"), RENEWAL("升级"), TRANSFER("转班"), REPETITION("重读/留级")
     */
    @NotBlank(message = "订单来源不能为空！")
    private String source ;

    /**
     * 订单来源渠道CODE，来自于主数据
     */
    @NotBlank(message = "订单来源渠道编码不能为空！")
    private String originChannel;

    /**
     * 用户账户ID：来自于统一用户中心下的账户ID。
     */
    private String accountId;

    /**
     * 业务日期：存在单据录入日期和实际业务发生日期不一致的情况。用来业务补录时记录实际发生日期。
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime bizDate;

    /**
     * 币种，直接“CNY”
     */
    private String currency = "CNY";

    /**
     * 付款类型，如先付费、后付费，来自于主数据
     */
    @NotBlank(message = "付款方式不能为空！")
    private String paymentType;

    /**
     * 订单备注
     */
    private String remark;

    /**
     * 创建订单的业务线，来自于主数据
     */
    @NotBlank(message = "业务线不能为空！")
    private String businessLine;

    /**
     * 订单创建人
     */
    private String createdBy;
    
    /**
     * 关联订单号
     */
    private String associatedOrderId;
    
    /** 订单行 */
    @NotEmpty(message = "订单行不能为空！")
    private List<NewOrderLineVO> lines;
    
    /** 订单优惠明细 */
    private List<NewOrderDiscountVO> discounts;
    
    /** 订单扩展属性 */
    private List<EntityExtendAttributeDTO> extendAttrs;
    
    /** 订单客户关系 */
    @NotNull(message = "订单购买客户信息不能为空！")
    private NewOrderCustomerRelationshipVO customer;

    /** 订单对应支付链接 */
    private String payUrl  ;
}
